<?php
session_start();
if(!isset($_SESSION['uid']))
 	{?>
		<script type="text/javascript">
			window.location="error.php";
		</script>
	<?php
 	}else
 		{
			include_once 'dataBaseConnectivityFile.php';
			$Deleteitem_id=$_REQUEST["stock_id"];
			
			$sql_get=mysql_query("SELECT (IMAGE_PATH) FROM stock where STOCK_ID = ".$Deleteitem_id."  ");
			while ($db_result2=mysql_fetch_assoc($sql_get))
				{
			      $IMAGE_PATH=$db_result2["IMAGE_PATH"];
				}
 				
				$files1 = $IMAGE_PATH;
				if(is_file($files1))
					{
			    		unlink($files1);
					}
				mysql_query("UPDATE stock set IMAGE_PATH='' where STOCK_ID=".$Deleteitem_id." ");
			    ?>
			    <script type="text/javascript">
			        alert("Main Image Deleted");
			        window.location="viewDetails.php?stock_id="+<?php echo $_REQUEST['stock_id']?>
			    </script>
				<?php
 		}
 	?>